﻿<navigation:Page x:Class="SinaDesktop.Views.UserFavorite" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           xmlns:converters="clr-namespace:SinaDesktop.Converters"
           xmlns:tooltipcontrol="clr-namespace:Silverlight.Controls.ToolTips;assembly=Silverlight.Controls.ToolTips"
           xmlns:LocalControls="clr-namespace:SinaDesktop.Controls" Style="{StaticResource PageStyle}"
           Title="UserFavorite">
    
    <UserControl.Resources>
        <converters:TextCountVisibilityConverter x:Key="TextCountVisibilityConverter"/>
        
        <Style x:Key="FluidItemsControlItemStyle"
               TargetType="LocalControls:FluidItemsControlItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="LocalControls:FluidItemsControlItem">
                        <ContentPresenter x:Name="contentPresenter"
                    		ContentTemplate="{TemplateBinding ContentTemplate}"
                    		Content="{TemplateBinding Content}"
                    		HorizontalAlignment="Stretch" Opacity="0">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="LayoutStates">
                                    <VisualState x:Name="BeforeLoaded"/>
                                    <VisualState x:Name="AfterLoaded">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="0:0:0.4" Duration="0:0:0.8" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="BeforeUnloaded"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </ContentPresenter>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="HtmlTextBlockStyle" TargetType="LocalControls:HtmlTextBlock">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Background" Value="#FFFFFFFF"/>
            <Setter Property="Foreground" Value="#FF666666"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="FontFamily" Value="Simsun,Segoe UI, Lucida Sans Unicode, Verdana" />
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                        <GradientStop Color="#FF718597" Offset="0.375"/>
                        <GradientStop Color="#FF617584" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="LocalControls:HtmlTextBlock">
                        <Grid x:Name="RootElement">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" To="#FF99C1E2" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="MouseOverBorder"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ReadOnly"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1" Opacity="1">
                                <Border x:Name="MouseOverBorder" BorderBrush="Transparent" BorderThickness="1">
                                    <ScrollViewer x:Name="ContentElement" BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}"/>
                                </Border>
                            </Border>
                            <Border x:Name="DisabledVisualElement" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}" Background="#A5F7F7F7" IsHitTestVisible="False" Opacity="0"/>
                            <Border x:Name="FocusVisualElement" BorderBrush="#FF6DBDD1" BorderThickness="{TemplateBinding BorderThickness}" IsHitTestVisible="False" Margin="1" Opacity="0"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <ScrollViewer VerticalScrollBarVisibility="Auto" 
                          HorizontalScrollBarVisibility="Disabled" BorderThickness="0" >
            <LocalControls:FluidItemsControl ItemsSource="{Binding}" ItemContainerStyle="{StaticResource FluidItemsControlItemStyle}" >
                <LocalControls:FluidItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="0">

                            <Grid Margin="2" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border BorderThickness="1" BorderBrush="White" VerticalAlignment="Top" HorizontalAlignment="Left" Width="50" Height="50" Margin="2">
                                    <Image Source="{Binding UsersItem.CustomizeImageURL, Converter={StaticResource StringConverter}}">
                                        <tooltipcontrol:ToolTipService.ToolTip>
                                            <tooltipcontrol:ToolTip x:Name="tooltipControl" 
                                                        Style="{StaticResource ToolTipStyle}" DisplayTime="00:00:15" InitialDelay="00:00:00">

                                                <tooltipcontrol:ToolTip.CloseAnimation>
                                                    <Storyboard Duration="00:00:01">
                                                        <DoubleAnimation From="1"
                                                         To="0"
                                                         Storyboard.TargetName="tooltipControl"
                                                         Storyboard.TargetProperty="Opacity" />
                                                    </Storyboard>
                                                </tooltipcontrol:ToolTip.CloseAnimation>

                                                <tooltipcontrol:ToolTip.OpenAnimation>
                                                    <Storyboard Duration="00:00:01">
                                                        <DoubleAnimation From="0"
                                                         To="1"
                                                         Storyboard.TargetName="tooltipControl"
                                                         Storyboard.TargetProperty="Opacity" />
                                                    </Storyboard>
                                                </tooltipcontrol:ToolTip.OpenAnimation>

                                                <tooltipcontrol:ToolTip.Content>
                                                    <Grid Margin="2">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="60" />
                                                            <ColumnDefinition Width="*" />
                                                        </Grid.ColumnDefinitions>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="Auto" />
                                                            <RowDefinition Height="*" />
                                                        </Grid.RowDefinitions>

                                                        <Border BorderThickness="1" Grid.RowSpan="2" VerticalAlignment="Top" BorderBrush="DarkGray" Margin="2" Width="54" Height="54">
                                                            <Image x:Name="imgFriendPic" Width="52" VerticalAlignment="Top" Margin="2" Source="{Binding UsersItem.CustomizeImageURL, Converter={StaticResource StringConverter}}"/>
                                                        </Border>

                                                        <StackPanel Orientation="Vertical" Grid.Column="1" Margin="2">
                                                            <StackPanel Orientation="Horizontal" >
                                                                <TextBlock x:Name="tbFriendName"  Margin="1" Text="{Binding UsersItem.FriendName}" Foreground="#FF58C3FD" FontFamily="SimSun" FontSize="12"/>
                                                                <Image Source="/SinaDesktop;component/Images/verify.png" Width="14" Margin="0,-6,0,0" Visibility="{Binding UsersItem.IsVerified, Converter={StaticResource VisibilityConverter}}"></Image>
                                                            </StackPanel>

                                                            <TextBlock x:Name="tbLocation" Text="{Binding UsersItem.Location}" Margin="1" Foreground="Gray" FontSize="12"/>
                                                            <Grid>
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="Auto" />
                                                                    <ColumnDefinition Width="Auto" />
                                                                    <ColumnDefinition Width="*" />
                                                                </Grid.ColumnDefinitions>
                                                                <StackPanel Orientation="Horizontal">
                                                                    <TextBlock Text="关注" Margin="1,0,0,0" Foreground="Gray" FontSize="12"/>
                                                                    <TextBlock Text="{Binding UsersItem.FriendCount}" Margin="3,0,0,0" Foreground="#FF58C3FD" FontSize="12"/>
                                                                </StackPanel>

                                                                <StackPanel Orientation="Horizontal" Grid.Column="1">
                                                                    <TextBlock Text="粉丝" Foreground="Gray" Margin="3,0,0,0" FontSize="12"/>
                                                                    <TextBlock Text="{Binding UsersItem.FollowerCount}" Margin="3,0,0,0" Foreground="#FF58C3FD"  FontSize="12"/>
                                                                </StackPanel>

                                                                <StackPanel Orientation="Horizontal" Grid.Column="2">
                                                                    <TextBlock Text="微博" Foreground="Gray" Margin="3,0,0,0" FontSize="12"/>
                                                                    <TextBlock Text="{Binding UsersItem.StatusesCount}" Margin="3,0,0,0" Foreground="#FF58C3FD" FontSize="12"/>
                                                                </StackPanel>

                                                            </Grid>

                                                        </StackPanel>

                                                        <TextBlock Text="简介:" HorizontalAlignment="Center" VerticalAlignment="Center"  Grid.Row="1" Grid.Column="0" FontSize="12" Visibility="{Binding Path=Text.Length, ElementName=tbDescription, Converter={StaticResource TextCountVisibilityConverter}}"/>
                                                        <TextBlock x:Name="tbDescription" Text="{Binding UsersItem.Description}" TextWrapping="Wrap" MaxWidth="300" Grid.Row="1" Grid.Column="1" FontSize="12"/>
                                                    </Grid>
                                                </tooltipcontrol:ToolTip.Content>

                                            </tooltipcontrol:ToolTip>
                                        </tooltipcontrol:ToolTipService.ToolTip>
                                    </Image>
                                </Border>

                                <StackPanel Grid.Column="1"  Margin="1" Orientation="Vertical">

                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock FontSize="13" Margin="2,0,0,0" Text="{Binding UsersItem.TwitterName}" 
                                                   Foreground="#FF31B2F9" FontFamily="SimSun"/>
                                        <Image Source="/SinaDesktop;component/Images/verify.png" Width="14" Margin="0,-6,0,0" Visibility="{Binding UsersItem.IsVerified, Converter={StaticResource VisibilityConverter}}"></Image>
                                    </StackPanel>

                                    <LocalControls:HtmlTextBlock Text="{Binding FriendTwitterContent}"
                                                            FontSize="13"
                                                            Margin="2,0,0,0" Style="{StaticResource HtmlTextBlockStyle}" 
                                                            Foreground="#FF666666"/>

                                </StackPanel>

                                <Grid Grid.Row="1" Grid.Column="1" Margin="1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <Border Grid.Column="1"  BorderThickness="1" BorderBrush="White" Visibility="{Binding IsShowThumbPic, Converter={StaticResource VisibilityConverter}}" Margin="2,0,0,0" >
                                        <HyperlinkButton x:Name="hbImageViewer" Click="hbImageViewer_Click"  IsHitTestVisible="True" >
                                            <Image Source="{Binding ThumbnailPic, Converter={StaticResource StringConverter}}" Margin="2"/>
                                        </HyperlinkButton>
                                    </Border>
                                </Grid>

                                <Border BorderThickness="1" Grid.Row="2" Grid.Column="1" Margin="1" Background="#FFF6F3F3"  BorderBrush="#FFF6F3F3" CornerRadius="3" Visibility="{Binding IsShowRetweet, Converter={StaticResource VisibilityConverter}}">

                                    <StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock FontSize="13" Text="{Binding RetweeterItem.UsersItem.TwitterName}" Margin="2" Foreground="#FF31B2F9" FontFamily="SimSun"/>
                                            <Image Source="/SinaDesktop;component/Images/verify.png" Width="14" Margin="0,-6,0,0" Visibility="{Binding RetweeterItem.UsersItem.IsVerified, Converter={StaticResource VisibilityConverter}}"></Image>
                                        </StackPanel>
                                        
                                        <LocalControls:HtmlTextBlock Text="{Binding RetweeterItem.RetweeterContent}"
                                                            FontSize="13" Style="{StaticResource HtmlTextBlockStyle}"
                                                            Background="#FFF6F3F3"
                                                            Foreground="#FF666666" 
                                                            Margin="2" />

                                        <Grid Margin="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <Border BorderThickness="1" Grid.Column="1" Margin="2" BorderBrush="White" Visibility="{Binding RetweeterItem.IsShowThumbPic, Converter={StaticResource VisibilityConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left" >
                                                <HyperlinkButton x:Name="retweetImageViewer" Click="retweetImageViewer_Click" IsHitTestVisible="True">
                                                    <Image Source="{Binding RetweeterItem.ThumbnailImageURL, Converter={StaticResource StringConverter}}" Margin="2"/>
                                                </HyperlinkButton>
                                            </Border>
                                        </Grid>

                                    </StackPanel>


                                </Border>

                                <Grid Grid.Row="3" Grid.Column="1" Margin="1,3,1,1">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock FontSize="11" Text="{Binding CreatedTime, Converter={StaticResource TimeConverter}}" Margin="2,0,0,0" Foreground="DarkGray"/>
                                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="2,0,0,0">
                                        <TextBlock FontSize="11" Text="来自" Foreground="DarkGray"/>
                                        <TextBlock FontSize="11" Text="{Binding SourceURL}"  Foreground="DarkGray" />
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right">
                                        <HyperlinkButton x:Name="btDelFavorite" Click="btDelFavorite_Click" Content="删除" FontSize="12" />
                                    </StackPanel>
                                </Grid>

                                <Rectangle Width="350" Grid.Row="4" Grid.ColumnSpan="2" Height="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="1,3,0,0" >
                                    <Rectangle.Fill>
                                        <LinearGradientBrush EndPoint="0.9,1" StartPoint="0,0.5" Opacity="0.8">
                                            <GradientStop Color="Gray"/>
                                            <GradientStop Color="White" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </LocalControls:FluidItemsControl.ItemTemplate>
            </LocalControls:FluidItemsControl>

        </ScrollViewer>
    </Grid>
</navigation:Page>
